package bankapplication.com.acme.bankapp.domain.bank;

import java.util.LinkedList;

public class Queue<T> {
  private LinkedList<T> list; 
  private boolean isclosed;
  
  public Queue(){
    list = new LinkedList<T>();
    isclosed = false;
  }
  
  public synchronized T get(){
    if(list.isEmpty()){
      return null;
    }
    else{
      return list.get(0);
    }
  }
  
  public synchronized void remove(){
    list.removeFirst();
  }

  public synchronized boolean add(T t){
    if(!isclosed){
      list.addLast(t);
      notifyAll();
    }
    return !isclosed;
  }
  
  public synchronized void close(){
    isclosed = true;
    notifyAll();
  }
  
  public boolean isEmpty(){
    return list.isEmpty();
  }
  
}
